resource "google_api_gateway_api" "<%= ctx[:primary_resource_id] %>" {
  provider = google-beta
  api_id = "<%= ctx[:vars]["name"] %>"
}

resource "google_api_gateway_api_config" "<%= ctx[:primary_resource_id] %>" {
  provider = google-beta
  api = google_api_gateway_api.<%= ctx[:primary_resource_id] %>.api_id
  api_config_id = "<%= ctx[:vars]["name"] %>"

  openapi_documents {
    document {
      path = "spec.yaml"
      contents = filebase64("test-fixtures/apigateway/openapi.yaml")
    }
  }
}

resource "google_api_gateway_gateway" "<%= ctx[:primary_resource_id] %>" {
  provider = google-beta
  region     = "us-central1"
  api_config = google_api_gateway_api_config.<%= ctx[:primary_resource_id] %>.id
  gateway_id = "<%= ctx[:vars]["name"] %>"
  display_name = "MM Dev API Gateway"
  labels = {
    environment = "dev"
  }
}
